//
//  ChannelToolBarButton.m
//  TestApplication
//
//  Created by Hanlingyu on 16/9/22.
//  Copyright © 2016年 ltq. All rights reserved.
//

#import "ChannelToolBarButton.h"
#import "Masonry.h"
#import "TAMacro.h"
@interface ChannelToolBarButton ()


@end

@implementation ChannelToolBarButton


- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        
        [self setUpChildrenView];
        [self addTap];
        
    }
    return self;
}

- (void)addTap {
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click:)];
    tap.numberOfTapsRequired = 1;
    [self addGestureRecognizer:tap];

    
}

- (void)clickAction {
    NSLog(@"点我了");
}

- (void)click:(UITapGestureRecognizer *)tap {
    [self.delegate clickAction];
}


- (void)setUpChildrenView {
    
    UIImageView *imageView = [[UIImageView alloc] init];
    imageView.backgroundColor = [UIColor grayColor];
    [self addSubview:imageView];
    _imageView = imageView;
    [_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.mas_centerY);
        make.width.height.mas_equalTo(20);
        make.centerX.mas_equalTo(self.mas_centerX).multipliedBy(0.25);
    }];
    
    
    UILabel *titleLabel = [[UILabel alloc] init];
    titleLabel.backgroundColor = [UIColor yellowColor];
    [self addSubview:titleLabel];
    _titleLabel = titleLabel;
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.mas_centerY);
        make.height.mas_equalTo(20);
        make.right.mas_equalTo(20);
    }];
    
}







/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
